package com.hqyj.controller;

import com.hqyj.pojo.BuyCar;
import com.hqyj.pojo.Item;
import com.hqyj.pojo.R;
import com.hqyj.service.BuyCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/buyCar")
public class BuyCarController {

    @Autowired
    BuyCarService buyCarService;
    //添加购物车
    @PostMapping("/car")
    public R addBuyCar(@RequestBody  Item item, HttpServletRequest request){
        return buyCarService.addBuyCar(item,request);
    }
    //查询我的购物车
    @GetMapping("/car")
    public R showBuyCar(HttpServletRequest request){
        return buyCarService.showBuyCar(request);
    }
    //删除我的购物车一条数据
    @DeleteMapping("/car")
    public R delBuyCar(Integer goodsId,HttpServletRequest request){
        return buyCarService.delBuyCar(goodsId,request);
    }
    //修改购物车
    @PutMapping ("/car")
    public R updateBuyCar(@RequestBody BuyCar buyCar, HttpServletRequest request){
        return buyCarService.updateBuyCar(buyCar,request);
    }

}
